package ru.ifmo.mlarinsky.classificator.classification;

import java.awt.Color;
import ru.ifmo.mlarinsky.classificator.model.Instrument;

import java.util.*;

/**
 * @author Mikhail Larinskiy
 */
public abstract class Classification {
    private final List<Instrument> indexes;
    private final Map<String, String> indexToSector;
    private final Map<String, Color> indexToColor;

    public Classification(List<Instrument> indexes, Map<String, String> indexToSector,
            Map<String, Color> indexToColor)
    {
        this.indexes = indexes;
        this.indexToSector = indexToSector;
        this.indexToColor = indexToColor;
    }

    public String getIndexSector(String index) {
        return indexToSector.get(index);
    }

    public Color getIndexColor(String index) {
        return indexToColor.get(index);
    }

    public List<Instrument> getIndexes() {
        return indexes;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("Classification:\n");
        for (Map.Entry<String, String> entry : indexToSector.entrySet()) {
            sb.append("\t").append(entry.getKey()).append(" -> ").append(entry.getValue()).append("\n");
        }
        return sb.toString();
    }
}
